package WaiBao;

import java.util.Arrays;

public class XuJiaNan {
    public static void main(String[] args) {
        String[] name = {"李晨(班长)", "欧阳进(副班长)", "小李(学习委员)", "上官婉儿(纪律委员)", "上官举", "张梦华", "李存燕", "李玲", "张小伙", "花花", "云中君", "李白",
                "韩雪", "王宇", "王雪", "何兆清", "何大勇", "李静进", "张小红", "李志伟", "王俊凯", "王源", "易烊千玺", "王晓刚", "王佳慧", "李时珍", "华佗", "扁鹊",
                "墨子", "徐佳楠(学生)"};//考生本人:徐佳楠(学生)
        int[] age = {19, 18, 21, 18, 19, 19, 19,20, 20, 19, 18, 21, 20, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 18, 20, 19};//考生本人年龄:19

        double[] jiajia1 = {84, 68, 76, 91, 90, 74, 74, 89, 81, 74, 91, 87, 85, 79, 65, 68, 69, 90, 86, 80, 92, 91, 95, 65, 75, 74, 94, 74, 80, 97};
        double[] jiajia2 = {77, 77, 65, 86, 80, 67, 74, 64, 83, 81, 72, 77, 66, 84, 65, 65, 76, 69, 76, 98, 72, 71, 95, 86, 75, 88, 84, 64, 81, 95};
        double[] jiajia3 = {68, 61, 84, 85, 75, 64, 78, 69, 80, 80, 93, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 73, 71, 84, 95};

        double lijian1 ;//代表每个学生的总分
        double lijian2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            lijian1  = jiajia1[i] + jiajia2[i] + jiajia3[i];
//            lijian2 = (lijian1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + lijian1);
//            System.out.println(name[i] + "的平均分为:" +lijian2);
//        }


        double nongye1 = 0,nongye2 = 0;
        double[] zhizao = new double[30];
//        for (int i = 0; i < 30; i++) {
//            nongye1= jiajia1[i] +  jiajia2[i] +  jiajia3[i];
//            nongye2 = (nongye1* 1.0) / 3;
//            zhizao[i] = nongye2;
//        }
//
//        for (int i = 0; i < zhizao.length - 1; i++) {
//            for (int j = 0; j < zhizao.length - i - 1; j++) {
//                if (zhizao[j] <zhizao[j + 1]) {
//                    double tep = zhizao[j];
//                    zhizao[j] =zhizao[j + 1];
//                    zhizao[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(zhizao[i]);
//        }


        double yingyu1 = 0,  yingyu2 = 0,yingyu3 = 0;//计算每门课的平均分
        double fayu1 = 0,fayu2 = 0, fayu3 = 0;//计算每门课标准差
        double qianpan1 = 0, qianpan2 = 0, qianpan3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i <jiajia1.length; i++) {
            he +=jiajia1[i];
        }
        yingyu1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" + yingyu1);
        double Sum = 0;
        for (int i = 0; i < jiajia2.length; i++) {
            Sum +=jiajia2[i];
        }
        yingyu2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" + yingyu2);
        double sum = 0;
        for (int i = 0; i <jiajia3.length; i++) {
            sum +=jiajia3[i];
        }
        yingyu3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" + yingyu3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i <jiajia1.length; i++) {
            c1 += (jiajia1[i] - yingyu1) * (jiajia1[i] - yingyu1);
        }
        fayu1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" + fayu1);
        for (int i = 0; i < jiajia2.length; i++) {
            c2 += (jiajia2[i] -yingyu2) * (jiajia2[i] -yingyu2);
        }
        fayu2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" +fayu2);

        for (int i = 0; i <jiajia3.length; i++) {
            c3 += (jiajia3[i] - yingyu3) * (jiajia3[i] - yingyu3);
        }
        fayu3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" + fayu3);
//////////
//        Arrays.sort(jiajia1);
//        Arrays.sort(jiajia2);
//        Arrays.sort(jiajia3);
//        qianpan1 = (jiajia1[14] +jiajia2[15]) * 1.0 / 2;
//        qianpan2 = (jiajia2[14] +jiajia2[15]) * 1.0 / 2;
//        qianpan3 = (jiajia3[14] + jiajia3[15]) * 1.0 / 2;
//        System.out.println("农业设施及环境调控的中位数为:" + qianpan1);
//        System.out.println("农业设施设计与制造的中位数为:" + qianpan2);
//        System.out.println("园艺植物设施栽培学的中位数为:" +qianpan3);




    }
}
